package cn.com.hiocde.myresume.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.media.MediaPlayer;

import cn.com.hiocde.myresume.R;

public class BgmService extends Service {
    private MediaPlayer player;

    public BgmService() {
        super();
    }

    @Override
    public void onCreate(){
        super.onCreate();

        player = MediaPlayer.create(this, R.raw.senia_piano);
        player.setLooping(true);

    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public int onStartCommand(Intent intent,int flags, int startId){
        int token=super.onStartCommand(intent,flags,startId);

        player.start();
        return token;
    }
    @Override
    public void onDestroy() {
// TODO Auto-generated method stub
        super.onDestroy();

        player.stop();
    }

}
